﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace RollBack.src.ui
{
    public partial class FileErrorsDialog : Form
    {
        public FileErrorsDialog()
        {
            InitializeComponent();
            this.Name = AppUI.m_DialogTitle;
            this.Text = AppUI.m_DialogTitle;
            this.m_iconLabel.Image = System.Drawing.SystemIcons.Error.ToBitmap();
            this.m_iconLabel.Text = "";
            this.m_iconLabel.Size = this.m_iconLabel.Image.Size;
        }

        /// <summary>
        /// Show the file error dialog box conditionally.  If the parameter 'show' is false then the function returns OK.
        /// </summary>
        /// <param name="jobKey"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        internal DialogResult showFileError(string jobKey, string msg,ref bool show)
        {
            DialogResult result = DialogResult.OK;
            if (show)
            {
                m_errorTextBox.Text = "Job Details: " + msg;
                m_jobDetails.Text = jobKey;
                m_jobDetails.SelectionLength = 0;
                result = this.ShowDialog( );
                if (result == DialogResult.OK)
                {
                    show = !m_doNotShowForThisRun.Checked;
                }
            }
            return result;
        }

        /// <summary>
        /// Set the internal state of the 'do not show checkbox' to control if this dialog will be displayed or not.
        /// </summary>
        /// <param name="value"></param>
        internal void showDialogForThisRun(bool value)
        {
            m_doNotShowForThisRun.Checked = value;
        }
    }
}
